home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
64'er Special 19
/
64er_Magazin_Sonderheft_19_19xx_Markt__Technik_de.d64
/
simplex 64 v.16
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
6KB
|
322 lines
100 rem ****************************
110 rem * *
120 rem * simplex 64 *
130 rem * *
140 rem * by *
150 rem * *
160 rem * m. buhtz *
170 rem * *
180 rem * grafenring 13 *
190 rem * 4230 wesel *
200 rem * tel.:0281/22431 *
210 rem * *
220 rem ****************************
230 :
240 print"[147] simplex 64[146]":print:print
250 print" 80 zeichenkarte ? (j/n)"
260 geta$
270 ifa$="j"then w=5:goto300
280 ifa$="n"then w=1:goto300
290 goto260
300 print:print:print
310 print" druckerausgabe ? (j/n)":print
320 geta$
330 ifa$="n"then410
340 ifa$="j"thene1=1:goto360
350 goto320
360 print" alle loesungen ? (1)":print
370 print" nur optimum ? (2)"
380 gete$
390 ife$<>"1"ande$<>"2"then380
400 ife$="2"thene1=2
410 print"[147] simplex 64[146]":print:print:print:print
420 input" anzahl strukturvariablen ";n
430 print
440 input" anzahl restriktionen ";m
450 m=m+1
460 print"[147] simplex 64[146]":print:print:print:print
470 dim a(m,n),b(m,n),e(m),x$(n),x1$(n),y$(m),y1$(m)
480 print" freie strukturvariablen ? (j/n)"
490 geta$
500 ifa$="j"thendim sp$(n) :goto 530
510 ifa$="n"then610
520 goto490
530 :
540 print"[147] freie strukturvariablen[146]":print
550 fori=1ton
560 print" in spalte"i"? (j/n)"
570 geta$
580 ifa$=""then570
590 ifa$="j"thensp$(i)="j"
600 nexti
610 :
620 print"[147] simplex 64[146]":print:print:print:print
630 print" gesperrte schlupfvariablen ? (j/n)"
640 geta$
650 ifa$="j"thendimz$(m):goto680
660 ifa$="n"then770
670 goto640
680 :
690 print"[147] gesperrte schlupfvariablen[146]":print
700 fori=1tom-1
710 print" in zeile"i"? (j/n)"
720 geta$
730 ifa$=""then720
740 ifa$="j"thenz$(i)="j"
750 nexti
760 :
770 rem *** eingabe koeffizienten ***
780 :
790 fori1=1tonstepw+1
800 print"[147]"
810 print,"*** simplex tableau ***" :print
820 x$(0)="rs "
830 print,
840 i2=i1+w
850 ifi2>=ntheni2=n
860 fori=i1toi2
870 x$(i)="x":x1$(i)=str$(i):x$(i)=x$(i)+x1$(i)
880 print"x"i,
890 nexti
900 ifi>nthenprint"rs ",
910 j1=j2+1
920 j2=j1+w
930 ifj2>=nthenj2=n
940 print
950 fori=0tom-1
960 y$(i)="y":y1$(i)=str$(i):y$(i)=y$(i)+y1$(i)
970 ifi=0thenprint:print;" z";:goto1000
980 ifi=1thenprint
990 print:print;"y"i;
1000 forj=j1toj2
1010 print,;:poke19,1:inputa(i,j):poke19,0
1020 nextj
1030 ifj>nthenprint,"";:poke19,1:inputa(i,0):poke19,0
1040 nexti
1050 nexti1
1060 ife1<>0thengosub2790
1070 :
1080 rem*** phase 0' s(spalte) ***
1090 :
1100 fori=1ton
1110 ifsp$(i)="j"thens=i:sp$(i)="s":goto1170
1120 nexti
1130 goto1220
1140 :
1150 rem*** phase 0' r(zeile) ***
1160 :
1170 r=int(rnd(1)*m)+1:t=t+1
1180 ifz$(r)="s"ora(r,s)=0then1170
1190 ift>100then2440
1200 t=0:goto1850
1210 :
1220 rem*** phase 0 r(zeile) ***
1230 :
1240 fori=1tom-1
1250 ifz$(i)="j"thenr=i:z$(i)="s":goto1310
1260 nexti
1270 goto1360
1280 :
1290 rem*** phase 0 s(spalte) ***
1300 :
1310 s=int(rnd(1)*n)+1:t=t+1
1320 ifsp$(s)="s"ora(r,s)=0then1310
1330 ift>100then2530
1340 t=0:goto1850
1350 :
1360 rem *** phase 1 r(zeile) ***
1370 :
1380 s=0:r=0
1390 fori=1tom-1
1400 ifa(i,0)<0thenr=i:goto1450
1410 nexti:goto1520
1420 :
1430 rem*** phase 1 s(spalte) ***
1440 :
1450 s=int(rnd(1)*n)+1:t=t+1
1460 ift>100then2620
1470 ifa(r,s)>=0then1450
1480 ifr<>0thent=0:goto 1850
1490 :
1500 rem *** phase 2 s(spalte) ***
1510 :
1520 s=0:r=0
1530 ifa(0,1)<0thens=1
1540 forj=2ton
1550 ifa(0,j)>=0 or a(0,j)>a(0,j-1) then 1570
1560 s=j
1570 next j
1580 ifs>0then1710
1590 ee=1
1600 ife1=2thengosub2800
1610 print
1620 print" **** rechnung beendet ****"
1630 print" **** optimum ****"
1640 ife1=0then1670
1650 open4,4:print#4:print#4,chr$(16)"11**** rechnung beendet ****"
1660 print#4,chr$(16)"11**** optimum ****":print#4:close4
1670 geta$
1680 ifa$<>""then2070
1690 goto1670
1700 :
1710 rem *** phase 2 r(zeile) ***
1720 :
1730 fori=1tom-1
1740 ifa(i,s)<=0thene(i)=10^38:goto1760
1750 e(i)=a(i,0)/a(i,s)
1760 nexti
1770 ife(1)>0thenr=1:goto1790
1780 e(1)=10^38
1790 fori=2tom-1
1800 ife(i)<=0 or e(i)>=e(i-1)then 1820
1810 r=i:goto1850
1820 nexti
1830 ifr<>1then2710
1840 :
1850 rem *** umrechnung ***
1860 :
1870 zw$=x$(s):x$(s)=y$(r):y$(r)=zw$
1880 b(r,s)=1/a(r,s)
1890 :
1900 forj=0ton
1910 ifj=sthen1930
1920 b(r,j)=a(r,j)/a(r,s)
1930 nextj
1940 :
1950 fori=0tom-1
1960 ifi=rthen1980
1970 b(i,s)=-a(i,s)/a(r,s)
1980 nexti
1990 :
2000 fori=0tom-1
2010 forj=0ton
2020 ifj=s or i=rthen2040
2030 b(i,j)=a(i,j)-a(i,s)*b(r,j)
2040 nextj
2050 nexti
2060 :
2070 rem *** umgerechnetes simplex tableau ***
2080 :
2090 it=it+1
2100 i1=0:i2=0:j1=0:j2=0
2110 fori1=1tonstepw+1
2120 ifn<=w+1then2130
2130 print"[147]"
2140 print" *** simplex tableau "it"[157].iteration ***":print
2150 print,
2160 i2=i1+w
2170 ifi2=>ntheni2=n
2180 fori=i1toi2
2190 printx$(i),
2200 nexti
2210 ifi>nthenprintx$(0)
2220 j1=j2+1
2230 j2=j1+w
2240 ifj2>=nthenj2=n
2250 fori=0tom-1
2260 print:printy$(i);
2270 forj=j1toj2
2280 a(i,j)=b(i,j)
2290 a(i,0)=b(i,0)
2300 print,"";:printint(a(i,j)*100+.5)/100;
2310 nextj
2320 ifj>nthenprint,"";:printint(a(i,0)*100+.5)/100
2330 nexti
2340 ifee<>1ori1>=nthen2370
2350 geta$
2360 ifa$=""then2350
2370 nexti1
2380 :
2390 ife1=1thengosub2790
2400 goto1070
2410 :
2420 rem *** meldungen ***
2430 :
2440 print:print" *** rechnung abgebrochen phase 0' ***"
2450 print" *** linearkombination spalten ***"
2460 ife1=2thengosub2800
2470 ife1=0thenend
2480 open4,4:print#4
2490 print#4,chr$(16)"11*** rechnung abgebrochen phase 0' ***"
2500 print#4,chr$(16)"11*** linearkombination spalten ***"
2510 print#4:close4:end
2520 :
2530 print:print" *** rechnung abgebrochen phase 0 ***"
2540 print" *** linearkombination zeilen ***"
2550 ife1=2thengosub2800
2560 ife1=0thenend
2570 open4,4:print#4
2580 print#4,chr$(16)"11*** rechnung abgebrochen phase 0 ***"
2590 print#4,chr$(16)"11*** linearkombination zeilen ***"
2600 print#4:close4:end
2610 :
2620 print:print" *** rechnung abgebrochen phase 1 ***"
2630 print" *** keine zulaessige loesung ***"
2640 ife1=2thengosub2800
2650 ife1=0thenend
2660 open4,4:print#4
2670 print#4,chr$(16)"11*** rechnung abgebrochen phase 1 ***"
2680 print#4,chr$(16)"11*** keine zulaessige loesung ***":print#4:close4:end
2690 print#4:close4:end
2700 :
2710 print:print" *** rechnung abgebrochen phase 2 ***"
2720 print" *** keine begrenzte loesung ***"
2730 ife1=2thengosub2800
2740 ife1=0thenend
2750 open4,4:print#4
2760 print#4,chr$(16)"11*** rechnung abgebrochen phase 2 ***"
2770 print#4,chr$(16)"11*** keine begrenzte loesung ***":print#4:close4:end
2780 print#4:close4:end
2790 :
2800 rem *** druckerausgabe ***
2810 :
2820 open4,4
2830 i2=0:j1=0:j2=0
2840 fori1=1tonstep4
2850 print#4,chr$(10)
2860 print#4,chr$(16)"10*** simplex tableau"it".iteration ***"
2870 print#4
2880 i2=i1+3
2890 ifi2>=ntheni2=n
2900 z=0
2910 fori=i1toi2
2920 z=z+1
2930 onzgosub3260,3270,3280,3290,3300
2940 :
2950 nexti
2960 ifi<=nthen2990
2970 i=0:z=z+1
2980 onzgosub3260,3270,3280,3290,3300
2990 j1=j2+1
3000 j2=j1+3
3010 ifj2>=nthenj2=n
3020 print#4
3030 fori=0tom-1
3040 ifi=0thenprint#4:print#4," z",:goto3070
3050 ifi=1thenprint#4
3060 print#4:print#4,y$(i),
3070 z=0
3080 forj=j1toj2
3090 ifit=0then3120
3100 a(i,j)=b(i,j)
3110 a(i,0)=b(i,0)
3120 z=z+1
3130 onzgosub3210,3220,3230,3240,3250
3140 nextj
3150 ifj<=nthen3180
3160 j=0:z=z+1
3170 onzgosub3210,3220,3230,3240,3250
3180 nexti
3190 nexti1
3200 print#4:close4:return
3210 print#4,chr$(16)"13"int(a(i,j)*100+.5)/100;:return
3220 print#4,chr$(16)"26"int(a(i,j)*100+.5)/100;:return
3230 print#4,chr$(16)"39"int(a(i,j)*100+.5)/100;:return
3240 print#4,chr$(16)"52"int(a(i,j)*100+.5)/100;:return
3250 print#4,chr$(16)"65"int(a(i,j)*100+.5)/100;:return
3260 print#4,chr$(16)"14"x$(i);:return
3270 print#4,chr$(16)"27"x$(i);:return
3280 print#4,chr$(16)"40"x$(i);:return
3290 print#4,chr$(16)"53"x$(i);:return
3300 print#4,chr$(16)"66"x$(i);:return